// 访问日志中间件

import log4js from "app/utils/log4js";
import { Context, Next } from "koa";

function AccessLogMiddleware(ctx: Context, next: Next) {
    const ip = ctx.header['X-Forwarded-For'] || ctx.ip;
    // 通过中间件记录用户访问
    log4js.info("", `${ip} | ${ctx.method} | ${ctx.path} | ${ctx.headers['user-agent']}`)
    return next();
}

export default AccessLogMiddleware
